package com.twu.biblioteca;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class UserRepository {

    private final Set<User> users = new HashSet<User>();

    /* default */ void add(User user) {
        users.add(user);

    }

    /* default */ Collection<User> findAll() {
        return users;
    }

    public User findByUsername(String username) {
        for (User user : users) {
            if (username.equals(user.getUsername())) {
                return user;
            }
        }
        return null;
    }

}
